import { http } from '@/common/service/service.js' 
import constants from '@/common/util/constants'
const UserServices = {
	state: {},

	mutations: {},

	actions: {
		// 登陆
		login({ commit }, params) {
		  return new Promise((resolve, reject) => {
			http.post('sso/basicLogin', params).then(response => {
			  uni.setStorageSync(constants.ACCESS_TOKEN,response);
			  resolve(response)
			}).catch(error => {
			  reject(error)
			})
		  })
		},
		getUserInfo({ commit }) {
			return new Promise((resolve, reject) => {
				http.get( 'sso/getInfo').then(response => {
					uni.setStorageSync(constants.USER_INFO,response.admin);
					resolve(response)
				}).catch(error => {
				  reject(error)
				})
			})
		},
		scanLogin({ commit },qrContent) {
			return new Promise((resolve, reject) => {
				http.post('sso/doQRCodeScan',qrContent).then(response => {
					resolve(response)
				}).catch(error => {
					reject(error)
				})
			})
		},
		userList({commit}){
			return new Promise((resolve,reject)=>{
				http.get(('user/list')).then(response => {
					resolve(response)
				}).catch(error => {
					reject(error)
				})
			})
		}
	}
	
}

export default UserServices
